//
//  UIButtonExtension.swift
//  cockpit
//
//  Created by Haijun Si on 2020/7/9.
//  Copyright © 2020 chenganrt. All rights reserved.
//

import UIKit

extension UIButton {
    func setImgAddTextMethod()
    {
        //使图片和文字水平居中显示
//        self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        self.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.center
            //文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
//        [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height + 20 ,- self.imageView.frame.size.width, 0.0,0.0)];
        
        self.titleEdgeInsets = UIEdgeInsets.init(top: self.imageView!.frame.size.height + 20, left: -(self.imageView!.frame.size.width), bottom: 0.0, right: 0.0)
        //图片距离右边框距离减少图片的宽度，其它不边
//        [self setImageEdgeInsets:UIEdgeInsetsMake(0.0, 0.0,10, - self.titleLabel.bounds.size.width)];
        self.imageEdgeInsets = UIEdgeInsets.init(top:0.0, left: 0.0, bottom: 10, right: -(self.titleLabel!.bounds.size.width))
        
    }
}
